--
-- Author: shunguo.chen
-- Date: 2018-06-27 19:58:58
--
-- MapBlessIconRender 祝福世界地图icon
--

local ClassRef = app.mvc.createRenderClass(...)

--data = MapInfo
function ClassRef.createWithData(data, node)
    local sprite = ClassRef.extend(node)
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end
function ClassRef.create(node)
    return ClassRef.createWithData(nil, node)
end

--
function ClassRef:init(data)
    self.super.init(self, data)

    display.uiAddClick(self._ui.bg1, function()
        if self._data then
            executeFunc(self._onClick, self)
        end
    end, true, 0.1)
    self:refresh()
end

function ClassRef:refresh()
    if self._data then
        local mapInfo = self._data
        self._ui.name:setString(mapInfo:getName())
        self._ui.Image_1:loadTexture(mapInfo:getIcon())
        self._ui.tips:setString(mapInfo:getZoneNumStr())
    end
end

function ClassRef:onBtnClick(cb)
    self._onClick = cb
end

return ClassRef
